<?php
/*
 * Copyright 2011 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * The Latitude service implementation
 *
 * Generated by http://code.google.com/p/google-api-php-client/
 * Generated from: https://www.googleapis.com/discovery/v0.3/describe/latitude/v1
 **/
class Location {
  public $accuracy;
  public $activityId;
  public $altitude;
  public $altitudeAccuracy;
  public $heading;
  public $kind;
  public $latitude;
  public $longitude;
  public $placeid;
  public $speed;
  public $timestampMs;
}

class LocationFeed {
  public $items;
  public $kind;
}

class apiLatitudeService {

  // Variables that the apiServiceResource implementation depends on
  private $serviceName = 'latitude';
  private $version = 'v1';
  private $restBasePath = '/latitude/v1/';
  private $rpcPath = '/rpc';
  private $io;
  // apiServiceResource's that are used internally
  private $currentLocation;
  private $location;

  /**
   * Constructs the internal service representations and does the auto-magic configuration required to drive them
   */
  public function __construct(apiClient $apiClient) {
    $apiClient->addService('latitude', 'v1');
    $this->io = $apiClient->getIo();
    $this->currentLocation = new apiServiceResource($this, $this->serviceName, 'currentLocation', json_decode('{"methods":{"delete":{"restPath":"currentLocation","rpcMethod":"latitude.currentLocation.delete","httpMethod":"DELETE","description":"Deletes the authenticated user\'s current location.","scopes":["https:\/\/www.googleapis.com\/auth\/latitude"]},"get":{"restPath":"currentLocation","rpcMethod":"latitude.currentLocation.get","httpMethod":"GET","description":"Returns the authenticated user\'s current location.","parameters":{"granularity":{"restParameterType":"query","description":"Granularity of the requested location.","type":"string"}},"response":{"$ref":"LatitudeCurrentlocationResourceJson"},"scopes":["https:\/\/www.googleapis.com\/auth\/latitude"]},"insert":{"restPath":"currentLocation","rpcMethod":"latitude.currentLocation.insert","httpMethod":"POST","description":"Updates or creates the user\'s current location.","request":{"$ref":"LatitudeCurrentlocationResourceJson"},"response":{"$ref":"LatitudeCurrentlocationResourceJson"},"scopes":["https:\/\/www.googleapis.com\/auth\/latitude"]}}}', true));
    $this->location = new apiServiceResource($this, $this->serviceName, 'location', json_decode('{"methods":{"delete":{"restPath":"location\/{locationId}","rpcMethod":"latitude.location.delete","httpMethod":"DELETE","description":"Deletes a location from the user\'s location history.","parameters":{"locationId":{"restParameterType":"path","required":true,"description":"Timestamp of the location to delete (ms since epoch).","type":"string"}},"parameterOrder":["locationId"],"scopes":["https:\/\/www.googleapis.com\/auth\/latitude"]},"get":{"restPath":"location\/{locationId}","rpcMethod":"latitude.location.get","httpMethod":"GET","description":"Reads a location from the user\'s location history.","parameters":{"granularity":{"restParameterType":"query","description":"Granularity of the location to return.","type":"string"},"locationId":{"restParameterType":"path","required":true,"description":"Timestamp of the location to read (ms since epoch).","type":"string"}},"parameterOrder":["locationId"],"response":{"$ref":"Location"},"scopes":["https:\/\/www.googleapis.com\/auth\/latitude"]},"insert":{"restPath":"location","rpcMethod":"latitude.location.insert","httpMethod":"POST","description":"Inserts or updates a location in the user\'s location history.","request":{"$ref":"Location"},"response":{"$ref":"Location"},"scopes":["https:\/\/www.googleapis.com\/auth\/latitude"]},"list":{"restPath":"location","rpcMethod":"latitude.location.list","httpMethod":"GET","description":"Lists the user\'s location history.","parameters":{"granularity":{"restParameterType":"query","description":"Granularity of the requested locations.","type":"string"},"max-results":{"restParameterType":"query","description":"Maximum number of locations to return.","type":"string"},"max-time":{"restParameterType":"query","description":"Maximum timestamp of locations to return (ms since epoch).","type":"string"},"min-time":{"restParameterType":"query","description":"Minimum timestamp of locations to return (ms since epoch).","type":"string"}},"response":{"$ref":"LocationFeed"},"scopes":["https:\/\/www.googleapis.com\/auth\/latitude"]}}}', true));
  }

  /**
   * Deletes the authenticated user's current location.
   *
   */
  public function deleteCurrentLocation() {
    return $this->currentLocation->__call('delete', array(array()));
  }

  /**
   * Returns the authenticated user's current location.
   *
   * @param $granularity   string Granularity of the requested location.
   */
  public function getCurrentLocation($granularity = null) {
    return $this->currentLocation->__call('get', array(array('granularity' => $granularity)));
  }

  /**
   * Updates or creates the user's current location.
   *
   * @param $postBody 
   */
  public function insertCurrentLocation($postBody) {
    return $this->currentLocation->__call('insert', array(array('postBody' => $postBody)));
  }

  /**
   * Deletes a location from the user's location history.
   *
   * @param $locationId   string Timestamp of the location to delete (ms since epoch).
   */
  public function deleteLocation($locationId) {
    return $this->location->__call('delete', array(array('locationId' => $locationId)));
  }

  /**
   * Reads a location from the user's location history.
   *
   * @param $locationId   string Timestamp of the location to read (ms since epoch).
   * @param $granularity   string Granularity of the location to return.
   */
  public function getLocation($locationId,
        $granularity = null) {
    return $this->location->__call('get', array(array('locationId' => $locationId,
        'granularity' => $granularity)));
  }

  /**
   * Inserts or updates a location in the user's location history.
   *
   * @param $postBody 
   */
  public function insertLocation($postBody) {
    return $this->location->__call('insert', array(array('postBody' => $postBody)));
  }

  /**
   * Lists the user's location history.
   *
   * @param $granularity   string Granularity of the requested locations.
   * @param $max_results   string Maximum number of locations to return.
   * @param $max_time   string Maximum timestamp of locations to return (ms since epoch).
   * @param $min_time   string Minimum timestamp of locations to return (ms since epoch).
   */
  public function listLocation($granularity = null,
        $max_results = null,
        $max_time = null,
        $min_time = null) {
    return $this->location->__call('list', array(array('granularity' => $granularity,
        'max-results' => $max_results,
        'max-time' => $max_time,
        'min-time' => $min_time)));
  }

  /**
   * @return the $io
   */
  public function getIo() {
    return $this->io;
  }

  /**
   * @return the $version
   */
  public function getVersion() {
    return $this->version;
  }

  /**
   * @return the $restBasePath
   */
  public function getRestBasePath() {
    return $this->restBasePath;
  }

  /**
   * @return the $rpcPath
   */
  public function getRpcPath() {
    return $this->rpcPath;
  }
}

